﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using cecbData;

namespace CECB.LeopoldMetrixCharts
{
    /// <summary>
    /// Interaction logic for check_Window1.xaml
    /// </summary>
    public partial class check_Window1 : Window
    {
        DSSEntities cecbContext;
        public check_Window1()
        {
            InitializeComponent();
            cecbContext = new DSSEntities();
            ProjectAutocompleteTextBox.ItemsSource = cecbContext.Projects;
        }

  
        private void ReportButton_Click(object sender, RoutedEventArgs e)
        {
            {


                try
                {
                    Projects prj = (Projects)ProjectAutocompleteTextBox.SelectedItem;
                    if (prj.proj_name.ToString().Length > 0)
                    {

                        new LeopoldMetrixCharts_Window1(prj.proj_reference ).ShowDialog();
                    }



                }
                catch (Exception ex)
                {
                    if (ProjectAutocompleteTextBox.SelectedItem == null)
                    {

                        MessageBox.Show("select a project first", "Message", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    else
                    {
                        MessageBox.Show("this function is currently unavailavle due to no values assign to this project", "Message", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }

            }


        }

        private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {

        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {

        }

        private void ProjectAutocompleteTextBox_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
        {
            string projectReferance = null;
            
            Projects proj = (Projects)ProjectAutocompleteTextBox.SelectedItem;
            try
            {
                projectReferance = proj.proj_reference;
            }
            catch (Exception)
            {

                return;
            }
            cecbClasses.Data_Adapters.LeopoldMetrixCharts.LeopoldMetrixCharts leopoldMetrixChart = new cecbClasses.Data_Adapters.LeopoldMetrixCharts.LeopoldMetrixCharts();
            
            textBox_PhysicalImpact.Text = leopoldMetrixChart.getPhysicalEnvironmentalAffection(projectReferance, "Physical Environment").ToString();
            textBox_SocialImpact.Text = leopoldMetrixChart.getPhysicalEnvironmentalAffection(projectReferance, "Social Environmental").ToString();
            textBox_EchologicalImpact.Text = leopoldMetrixChart.getPhysicalEnvironmentalAffection(projectReferance, "Ecological Environmental").ToString();
            
            label_physicalImpactPresentage.Content = leopoldMetrixChart.getPhysicalEnvironmentalAffection(projectReferance, "Physical Environment").ToString();
            label_sociologicalImpactPresentage.Content = leopoldMetrixChart.getPhysicalEnvironmentalAffection(projectReferance, "Social Environmental").ToString();
            label_EchologicalImpactPresentage.Content = leopoldMetrixChart.getPhysicalEnvironmentalAffection(projectReferance, "Ecological Environmental").ToString();
           
            label_presentageMark1.Content = "%";
            label_presentageMark2.Content = "%";
            label_presentageMark3.Content = "%";
        }

        private void ButtonClose_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
